# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer: Grigory Kirillov <txgk@bk.ru>
pkgname=yyjson
pkgver=0.5.1
pkgrel=0
pkgdesc="High performance JSON library written in ANSI C"
url="https://github.com/ibireme/yyjson"
# s390x: test #8 strangely hangs
arch="all !s390x"
license="MIT"
makedepends="cmake samurai"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://github.com/ibireme/yyjson/archive/$pkgver/yyjson-$pkgver.tar.gz"

build() {
	cmake -B builddir -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DBUILD_SHARED_LIBS=ON \
		-DYYJSON_BUILD_TESTS=ON
	cmake -B builddir-static -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=MinSizeRel
	cmake --build builddir
	cmake --build builddir-static
}

check() {
	ctest --output-on-failure --test-dir builddir
}

package() {
	DESTDIR="$pkgdir" cmake --install builddir
	DESTDIR="$pkgdir" cmake --install builddir-static
	for file in README.md doc/API.md doc/BuildAndTest.md doc/DataStructure.md
	do
		install -Dm644 "$file" -t "$pkgdir"/usr/share/doc/"$pkgname"/
	done
}

sha512sums="
dbae242ee023e872184b4f28e32e3044adfa0cf00e0f480e961a0c8979ff69b2d2f95a33504f10883eba16b68db0adce3a38c2f99dcb6f94eb73a107b89cca95  yyjson-0.5.1.tar.gz
"
